package com.lixiaoyi.emp.dao.impl;

import com.lixiaoyi.emp.dao.IEmpManagerDao;
import com.lixiaoyi.emp.entity.EmpManager;
import com.lixiaoyi.emp.utils.DbUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

/**
 * @Author 李小毅
 * @Description
 * @Date 2022-05-12
 */

public class EmpManagerDaoImpl implements IEmpManagerDao {

    //1.定义QueryRunner用来连接数据库
    private QueryRunner queryRunner = new QueryRunner(DbUtils.getDs());

    @Override
    public EmpManager select(String username) {
        try {

            EmpManager empManager = queryRunner.query( "select * from empmanager where username = ?;", new BeanHandler<EmpManager>(EmpManager.class), username);
            return empManager;

        } catch (SQLException e) {
            e.printStackTrace();
        }

        return null;
    }
}
